home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 66
/
Vol 66.iso
/
games
/
bluep.swf
/
scripts
/
__Packages
/
Enemy.as
< prev
next >
Wrap
Text File
|
2013-04-24
|
3KB
|
99 lines
class Enemy extends MovieClip
{
function Enemy()
{
super();
this._damage = 1;
this._life = 2;
this._holdMovement = true;
this.enemyIncrem2 = 0;
this.enemySetBase2 = _global.FPSforTweenClass * 1;
this._dead = false;
}
function onEnterFrame()
{
this.rotateEnemy();
this.enemyShoot();
this.enemyDie();
}
function enemyDie()
{
var i = 0;
while(i < _root.arrBullets.length)
{
var ObjRef = eval("_root." + _root.arrBullets[i]);
if(this.hitTest(ObjRef._x,ObjRef._y))
{
if(!ObjRef._enemy)
{
var rotRan = 1 + Math.floor(Math.random() * 360);
if(this._life >= 1)
{
var hitAnName = "shield_hits" + _root.getNextHighestDepth();
_root.attachMovie("shield_hits",hitAnName,_root.getNextHighestDepth());
_root[hitAnName]._x = ObjRef._x;
_root[hitAnName]._y = ObjRef._y;
_root[hitAnName]._rotation = rotRan;
}
if(this._life > 0)
{
_root.removeCallback(_root.arrBullets[i]);
_root[_root.arrBullets[i]].removeMovieClip();
_root.arrBullets.splice(i,1);
this._life--;
}
else
{
this._dead = true;
_root.removeCallback(_root.arrBullets[i]);
_root[_root.arrBullets[i]].removeMovieClip();
_root.arrBullets.splice(i,1);
var deathAnimationName = "death_" + _root.getNextHighestDepth();
_root.enemyLayer.attachMovie("enemy_1_death",deathAnimationName,_root.getNextHighestDepth());
_root.enemyLayer[deathAnimationName]._x = this._x;
_root.enemyLayer[deathAnimationName]._y = this._y;
_root.enemyLayer[deathAnimationName]._rotation = rotRan;
_root.ReportEnemyDeath(this._name);
this.removeMovieClip();
}
}
}
i++;
}
}
function dieNow()
{
trace("die now called");
_root.killAllAnimations(this._x,this._y);
this.removeMovieClip();
}
function rotateEnemy()
{
if(!this._dead)
{
var _loc3_ = new Vector();
_loc3_._x = _root.pointer._x - this._x - _root.enemyLayer._x;
_loc3_._y = _root.pointer._y - this._y - _root.enemyLayer._y;
var _loc4_ = Math.atan2(_loc3_._y,_loc3_._x);
var _loc5_ = 360 * _loc4_ / 6.283185307179586;
this._rotation = _loc5_;
}
else
{
this._rotation = this._rotation;
}
}
function enemyShoot()
{
if(this.enemyIncrem2 >= this.enemySetBase2)
{
var _loc3_ = new Vector();
_loc3_._x = Math.cos(3.141592653589793 * this._rotation / 180) * 7;
_loc3_._y = Math.sin(3.141592653589793 * this._rotation / 180) * 7;
_root.shootEnemyGun(_loc3_._x,_loc3_._y,this._x + _root.arena._x,this._y + _root.arena._y);
this.enemyIncrem2 = 0;
}
this.enemyIncrem2 = this.enemyIncrem2 + 1;
}
}